
import requests
from uuid import uuid4

def upload_file(local_path):
    url = 'http://116.62.130.29/v1/files/upload'
    headers = {'Authorization': 'Bearer app-WqiQCDEUM0Hlm8Jvpj0jGtNu'}
    files = {("file", (str(uuid4())+'.pdf', open(local_path, "rb"), "application/pdf")),}
    data = {"user": "abc-123"}
    a = requests.post(url, headers=headers, files=files, json=data)
    return a.json()['id']

print(upload_file('docs/01-GPT系列模型.pdf'))


url = "http://116.62.130.29/v1/workflows/run"
headers = {
    "Authorization": "Bearer app-WqiQCDEUM0Hlm8Jvpj0jGtNu",
    "Content-Type": "application/json"
}
data = {
        "inputs": {
            "files":
            [{
             "transfer_method": "local_file",
             "upload_file_id": "322e5804-93da-49ed-bf4a-27cf3c3a5491",
             "type": "document"
            }]
    },
    "user": "abc-123"
}
a = requests.post(url,headers=headers,json=data)
print(a.text)

